<?php
//require section
require_once dirname(__FILE__) . '/shared/config/config.php';
require_once DOCUMENT_ROOT . DIR_INCLUDE . 'check_session.php';
require_once DOCUMENT_ROOT . DIR_INCLUDE . 'check_outside_booking.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_cinemas.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_movies.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_booking.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_seats.php';
$title = 'Home Page';


?>

<!DOCTYPE html>
<html>
<head>
    <?php
        require_once DOCUMENT_ROOT . DIR_INCLUDE . 'head.php';
    ?>
    <?php
    if (!empty($skrill_payment)) {
    ?>
    <script type="text/javascript">
    $(document).ready(function() {
        $('#skrill').modal('show');
    });
    </script>
    <?php
    }
    ?>
</head>
<body>
<div class="ts-body-container">
    <div class="ts-wrapper">
        <!--<div class="ui grid">-->
        <div class="padding-top-large row">
            <?php
                require_once DOCUMENT_ROOT . DIR_INCLUDE . 'header.php';

            ?>
            <div class="ui segment breadcrumb" style="margin-top: 25px; margin-left: 20px;">
                <a class="active section" href="index.php">Home</a>
            </div>
        </div>
        <div class="ui grid">
            <div class="row">
                <?php require_once DOCUMENT_ROOT . DIR_INCLUDE . 'book_ticket.php'; ?>
                <div class="twelve wide column">
                    <h1>Now Showing</h1>

                    <div class="ui orange segment">
                        <div class="ui stackable items">
                            <div class="row">
                                <?php
                                    $list = api_movies::get_all_movies_with_now_showing_and_number(3);
                                    if (empty($list) || count($list) == 0) {
                                        echo "Not movie found.";
                                    } else {
                                        foreach ($list as $item) {
                                            ?>
                                            <div class="item" onclick="window.location = 'movie_detail.php?m_id=<?php echo $item['id'] ?>#container'">
                                                <div class="image">
                                                    <img src="<?php echo LINK_ROOT . DIR_SHARED_UPLOAD_IMAGES_POSTERS . $item['poster']; ?>">

                                                </div>

                                                <div class="content">
                                                    <div class="name"><?php echo $item['title']; ?></div>
                                                    <p class="description">
                                                        <?php
                                                            if (strlen($item['description']) < 100) {
                                                                echo $item['description'];
                                                            } else {
                                                                echo substr($item['description'], 0, 100) . '<span class="ts-red">....[more]</span>';
                                                            }
                                                        ?>
                                                    </p>
                                                </div>
                                            </div>
                                        <?php
                                        }
                                    } ?>
                            </div>
                        </div>
                    </div>

                    <h1>Coming Soon</h1>

                    <div class="ui orange segment">
                        <div class="ui stackable items">
                            <div class="row">
                                <?php
                                    $list = api_movies::get_all_movies_with_comming_soon_and_number(3);
                                    if (empty($list) || count($list) == 0) {
                                        echo "Not movie found.";
                                    } else {
                                        foreach ($list as $item) {
                                            ?>
                                            <div class="item" onclick="window.location = 'movie_detail.php?m_id=<?php echo $item['id'] ?>#container'">
                                                <div class="image">
                                                    <img src="<?php echo LINK_ROOT . DIR_SHARED_UPLOAD_IMAGES_POSTERS . $item['poster']; ?>">
                                                </div>
                                                <div class="content">
                                                    <div class="name"><?php echo $item['title']; ?></div>
                                                    <p class="description"><?php
                                                            if (strlen($item['description']) < 100) {
                                                                echo $item['description'];
                                                            } else {
                                                                echo substr($item['description'], 0, 100) . '<span class="ts-red">....[more]</span>';
                                                            }
                                                        ?></p>
                                                </div>
                                            </div>
                                        <?php
                                        }
                                    } ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
<!-- SKRILL MODAL -->
<div id="skrill" class="ui modal">
  <i class="close icon"></i>
  <?php
  if (!empty($skrill_payment) && $skrill_payment === "paid") {
  ?>
  <div class="header">
    SKRILL Payment Successfully & Finished
  </div>
  <div class="content">
    Congratulations, Booking successfully! Now, a booking code is sent to your email and phone number. Remember your code when you come to cinema.
  </div>
  <?php
  } else {
  ?>
  <div class="header">
    SKRILL Payment Failed
  </div>
  <div class="content">
    We haven't received your payment. Please booking again!
  </div>
  <?php
  }
  ?>
  <div class="actions">
    <div class="ui orange button">
      OK
    </div>
  </div>
</div>
<!-- END SKRILL MODAL -->
        
        <div class="row">
            <?php
                require_once DOCUMENT_ROOT . DIR_INCLUDE . 'footer.php';
            ?>
        </div>
        <!--</div>-->
    </div>
</div>
</body>
</html>